<script setup lang="ts">
import { Search } from '@element-plus/icons-vue'

interface Emits {
    (e: 'update:modelValue', value: string): void;
    (e: 'on-btn-click'): void;
}

interface Props {
    modelValue?: string;
}

defineProps<Props>()
const $emit = defineEmits<Emits>()

</script>

<template>
    <div class="search">
        <input type="text" placeholder="搜索产品编号/名称" :value="modelValue"
            @input="($event) => $emit('update:modelValue', ($event?.target as HTMLInputElement)?.value)"
            @keydown.enter="$emit('on-btn-click')">
        <el-icon color="#BBBBBB" style="cursor: pointer;" @click="$emit('on-btn-click')">
            <Search />
        </el-icon>
    </div>
</template>

<style lang="less" scoped>
.search {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 330px;
    height: 30px;
    border-radius: 15px;
    background-color: rgba(255, 255, 255, 1);
    color: rgba(16, 16, 16, 1);
    border: 1px solid rgba(187, 187, 187, 1);
    padding-left: 20px;
    padding-right: 10px;
    margin-bottom: 26px;

    input {
        border: none;
        outline: none;
        height: 100%;
        width: 100%;
        line-height: 30px;
        font-size: 13px;
    }
}
</style>
